package com.szt.sy.controller.api.open;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.szt.sy.controller.base.ApiBaseController;
import com.szt.sy.entity.blog.ArticleTag;
import com.szt.sy.service.blog.articletag.ArticleTagService;
import com.szt.sy.vo.rep.base.RepPageVO;

/***
 * 接口-开放-文章标签
 * 
 * @author wwy
 *
 */
@RestController
@RequestMapping("api/open/article/tag")
public class ApiOpenArticleTagController extends ApiBaseController {
	
	@Autowired
	private ArticleTagService articleTagService;
	
	@PostMapping("page")
	public RepPageVO<List<ArticleTag>> articlePage(Integer currentPage, Integer pageSize) {
		RepPageVO<List<ArticleTag>> repVO = new RepPageVO<>();
		Page<ArticleTag> page = new Page<>(currentPage, pageSize);
		EntityWrapper<ArticleTag> wrapper = new EntityWrapper<>();
		wrapper.orderBy("num", false);
		Page<ArticleTag> pageInfo = articleTagService.selectPage(page, wrapper);
		repVO.setCommonSuccess();
		repVO.setData(pageInfo.getRecords());
		repVO.setCurrentPage(pageInfo.getCurrent());
		repVO.setTotalPage(pageInfo.getPages());
		repVO.setTotalResult(page.getTotal());
		return repVO;
	}
}
